fix(near): correct token attribution in tx parsing, harden intents actuals - #12525
Conversation
…tuals A NEAR intents swap displayed an absurd USDT amount. Two defects on the actual-buy-amount paths: - parseTx labeled every nep141 event with the transaction's top-level receiver as token contract, so a settlement's USDT transfer to the user was attributed to intents.near - the actual-amount lookup never matched the buy asset and fell through. Events are now attributed to the receipt's executor, the contract that actually emitted them. - near-intents checkTradeStatus reported swapDetails.amountOut as the actual buy amount in every state - it is only destination-denominated on terminal success, so in-flight and refund states no longer supply it. Verified live against the affected settlement tx: the parse now returns the exact received amount under the correct usdt.tether-token.near asset id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 1 minute You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
A NEAR Intents swap (NEAR → USDT on NEAR) displayed an absurd completed amount ("5,651,948,527,226,708,191.126278 USDT" for a ~1 USDT swap). Investigation traced every source feeding the displayed actual amount; two real defects were found and fixed on those paths:
parseTxtoken mis-attribution: every NEP-141 event in a transaction was labeled with the transaction's top-level receiver as the token contract. For intents settlements (receiverintents.near), the USDTft_transferto the user was attributed tonep141:intents.near, souseActualBuyAmountCryptoPrecision's chain-side lookup could never match the buy asset and the fallback chain silently failed. Events are now attributed per-receipt to the executor — the contract that actually emitted the event — which is correct for any transaction shape (delegated, batched, multi-contract).checkTradeStatusover-trustedswapDetails.amountOut: it was reported asactualBuyAmountCryptoBaseUnitin every status. It is only reliably destination-denominated on terminalSUCCESS; in-flight and refund states no longer supply it, so a transient settlement-phase value can never be persisted as the actual amount (once written, it was never re-read from a corrected poll if polling stopped).Verified live against the affected swap's settlement transaction (
DJaLoG…/ depositc0f7e4…): the parse now returns exactlyReceive 996459undernear:mainnet/nep141:usdt.tether-token.near— matching the provider's ownswapDetails.amountOutand explorer (0.996459 USDT). Also verified the full quote path is decimals-clean end to end: provider registry (6 decimals), our asset (precision 6), request amount (wNEAR 24dp), quoteamountOut(6dp).Issue (if applicable)
closes #
Risk
Low. NEAR-only parsing plus one status-field gate. The executor attribution strictly improves correctness for all NEP-141 event shapes; plain
ft_transfertransactions (receiver = token contract = executor) are unchanged.NEAR transaction parsing for display/actual-amount purposes and NEAR Intents swap status reporting. No transaction construction changes.
Testing
Engineering
parseTxagainst the affected settlement tx before/after: mislabelednep141:intents.near→ correctnep141:usdt.tether-token.near, value exact (996459).amountOutonSUCCESS.Operations
Screenshots (if applicable)
🤖 Generated with Claude Code